package com.nc.delivery_project.server.domain;

/**
 * Created by miroshnik on 1/28/2015.
 */
public class Currency {
    
    private int id;
    
    private String title;
    
    private double rate;

    public Currency(int id, String title, double rate) {
        this.id = id;
        this.title = title;
        this.rate = rate;
    }

    public Currency(String title, double rate) {
        this(0, title, rate);
    }

    public Currency(int id) {
        this(id, null, 0d);
    }

    public Currency() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public double getRate() {
        return rate;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Currency)) return false;

        Currency currency = (Currency) o;

        if (Double.compare(currency.rate, rate) != 0) return false;
        if (title != null ? !title.equals(currency.title) : currency.title != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result;
        long temp;
        result = title != null ? title.hashCode() : 0;
        temp = Double.doubleToLongBits(rate);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        return result;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Currency{");
        sb.append("id=").append(id);
        sb.append(", title='").append(title).append('\'');
        sb.append(", rate=").append(rate);
        sb.append('}');
        return sb.toString();
    }
}
